home *** CD-ROM | disk | FTP | other *** search
/ The Best of Down Under Games / The Best of Down Under Games.iso / 3dfx Screen Savers / VoodooLights / Sources / cell_tp2.c < prev    next >
C/C++ Source or Header  |  1997-07-23  |  2KB  |  103 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7.  
  8. #include <math.h>
  9. #include <stdlib.h>
  10. #include <glide.h>
  11.  
  12. #include "defines.h"
  13. #include "mat.h"
  14. #include "rgb.h"
  15. #include "tex.h"
  16. #include "cam.h"
  17. #include "cell.h"
  18.  
  19. #include "cell.h"
  20. #include "cell_util.h"
  21. #include "cell_tp1.h"
  22. #include "cell_tp2.h"
  23. #include "cell_tp3.h"
  24. #include "cell_tp4.h"
  25.  
  26. static Bool first_init = True ;
  27. static GrMipMapId_t tp2_texture_src ;
  28.  
  29. static void tp2_acc_cell(Cell *c) 
  30. {
  31.   int n ;
  32.   Cell **p ;
  33.  
  34.   c->acc = xyz_Zero ;
  35.  
  36.   p = cell_get_cells_by_type( CellType1, & n ) ;
  37.   cutl_closest_interaction( c, p, n, 6000.0, 1.0 ) ;
  38.  
  39.   p = cell_get_cells_by_type( CellType2, & n ) ;
  40.   cutl_closest_interaction( c, p, n, -80000.0, 3.0 ) ;
  41.  
  42. }
  43.     
  44. static void tp2_reproduce_cell( Cell *c) 
  45. {
  46.     c->children[ c->n_chld++ ] = ctp3_Constructor( c ) ;
  47.     c->reproduce_cell = cell_menopause ;                // nπo hß mais reproduτπo
  48. }
  49.  
  50. void tp2_set_glide_state( void )
  51. {
  52.     if( first_init ) {
  53.         first_init = False ;
  54.         tp2_texture_src = tex_InitTexture("flare1.3df") ;
  55.     }    
  56.     guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB ) ;
  57.     guAlphaSource( GR_ALPHASOURCE_ITERATED_ALPHA );    
  58.     grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ZERO );
  59.     tex_SetTexSource( tp2_texture_src ) ;
  60. }
  61.  
  62. Cell *ctp2_Constructor( Cell *dad )
  63. {
  64.  
  65.   Cell *c = cell_Constructor( CellType2 ) ;
  66.  
  67.   c->max_speed = 80.00 ;
  68.  
  69.   c->dad = dad ;
  70.  
  71.   c->max_chld = 1 ;
  72.   c->p_chld = 1.0 ;
  73.   c->adulthood = 16.0 ;
  74.   c->size = 48.0 ;
  75.   if( dad ) {
  76.  
  77.     c->pos.x = dad->pos.x + 1 * ( 1 - 2 * rnd()) ;
  78.     c->pos.y = dad->pos.y + 1 * ( 1 - 2 * rnd()) ;
  79.     c->pos.z = dad->pos.z + 1 * ( 1 - 2 * rnd()) ;
  80.   
  81.     c->generation = dad->generation + 1 ;
  82.     c->adulthood = dad->adulthood ;
  83.   }    cutl_random_pos( 500.0, c ) ;
  84.  
  85.   c->color.r = 255.0 ;
  86.   c->color.g = 250.0 ;
  87.   c->color.b = 252.0 ;
  88.   c->color.a = 255.0 ;
  89.  
  90.   c->acc_cell = tp2_acc_cell ;
  91.   c->reproduce_cell = tp2_reproduce_cell ;
  92.  
  93.   return c ;
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.     
  101.  
  102.